﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.OracleClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Util;

namespace DAL
{
    public class UserDao1
    {
        public static string connstr = ConfigurationManager.ConnectionStrings["connstr"].ConnectionString;
        public int insertUser(string name) {
            //string sql = "insert into t_classes values(sq_classes.nextval,c_cName ='" + name+ "')";
            // string ConnectionString = "Data Source=orcl; User Id=scott; Password=root"; //连接字符串
       
        OracleConnection conn = new OracleConnection(connstr); //创建一个新连接
            try

            {
                conn.Open(); //打开连接

                OracleCommand cmd = conn.CreateCommand();
                cmd.CommandText = "SELECT * FROM t_classes"; //SQL语句
                OracleDataReader rs = cmd.ExecuteReader();
                while (rs.Read()) //读取数据，如果rs.Read()返回为false的话，就说明到记录集的尾部了
                {
                    MessageBox.Show(rs.GetString(1));
                }
                rs.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conn.Close();
            }
            // return DBHelpr.ExecuteNonQuery(sql);
            return 1;
        }
        
    }
}
